#ifndef _SRC_NET_HTTP_HTTP_RESPONSE_H_
#define _SRC_NET_HTTP_HTTP_RESPONSE_H_

#include <map>
#include <string>
#include <string_view>

#include "src/base/utils.h"

namespace fio66::net {
enum class HttpStatusCode {
  kUnknow,
  k200OK = 200,
  k301MovedPermanently = 301,
  k400BadRequest = 400,
  k404NotFound = 404
};

class Buffer;
class HttpResponse {
 public:
  DISALLOW_COPY_AND_ASSIGN(HttpResponse)

  explicit HttpResponse(bool close);

  void SetStatusCode(HttpStatusCode code);
  void SetStatusMessage(std::string_view message);
  void SetContentType(std::string_view content_type);
  void SetCloseConnection(bool on);
  bool CloseConnection() const;
  void AddHeader(std::string_view key, std::string_view value);
  void SetBody(std::string_view body);
  void AppendToBuffer(Buffer* out) const;

  private:
  std::map<std::string, std::string> headers_;
  HttpStatusCode status_code_ = HttpStatusCode::kUnknow;
  std::string status_message_;
  std::string body_;
  bool close_connection_;
};

}  // namespace fio66::net

#endif  // _SRC_NET_HTTP_HTTP_RESPONSE_H_
